home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 49
/
Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso
/
-serious-
/
comms
/
other
/
dc-sx107install
/
sx
/
developer
/
sasc
/
example2.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-11-29
|
2KB
|
91 lines
/*
----------------------------------------------------------
System-X door using EXEC-MESSAGES (The prefered method!)
----------------------------------------------------------
See the botton of this source!
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <proto/exec.h>
#include <proto/dos.h>
struct MsgPort *bbsport;
struct JHMessage
{
struct Message Msg;
char String[200];
long Data,
Command;
} themsg;
void PS(char * str);
void XIMFunction(int func, long data, char * str);
void Door(void);
BOOL sx;
int main(int argc, char *argv[])
{
if(!argv[1] || argv[1][0]==0)
PutStr("This program requires System-X BBS Software\n");
else {
sprintf(buf, "AEDoorPort%s", argv[1]);
bbsport = FindPort(buf);
if(bbsport)
{
XIMFunction(1, 0, 0); /* function 1 = register */
/* find out if we are under SYSTEM-X or AmiExpress */
if(strcmp(themsg.String,"SX")==0) sx=TRUE; else sx=FALSE;
Door();
XIMFunction(2, 0, 0); /* function 2 = shutdown */
}
}
}
void PS(char * str)
{
if(sx) XIMFunction(1500, (long)str, 0); else XIMFunction(4, 0, str);
}
void XIMFunction(int func, long data, char * str)
{
struct MsgPort *replyport;
replyport = CreateMsgPort();
if(replyport)
{
themsg.Msg.mn_Length = sizeof(struct JHMessage);
themsg.Msg.mn_ReplyPort = replyport;
themsg.Data = data;
themsg.Command = func;
if(str && str[0]!=0) strcpy(themsg.String, str);
PutMsg(bbsport, (struct Message *)&themsg);
WaitPort(replyport);
GetMsg(replyport);
DeleteMsgPort(replyport);
}
}
/* ============ PUT YOUR DOOR IN HERE ============== */
void Door(void)
{
PS("Hello! Welcome to a test door\r\n\r\n");
XIMFunction(5, 40, "Please enter some text: ");
PS("\r\n\r\nYou entered: ");
PS(themsg.String);
PS("\r\n\r\nExiting...\r\n\r\n");
}